package pl.factat.gfk.Display;

import java.awt.*;
import java.awt.geom.Ellipse2D;

/**
 * Created with IntelliJ IDEA.
 * User: adam
 * Date: 08.01.13
 * Time: 23:15
 * Defines a circle that can be easily used to drag it around. Not necessary, but looks cool!
 */
public class DraggableCircle {
    private int x =0;
    private int y=0;
    private int size = 0;

    public DraggableCircle(int x, int y, int size)
    {
        this.x = x;
        this.y = y;
        this.size = size;
    }
    public void draw(Graphics g2d)
    {
        g2d.drawOval(x, y, size, size);
    }

    public boolean isOnCircle(int x, int y)
    {
        int centerx = this.x + size/2;
        int centery = this.y + size/2;
        int dx = centerx - x;
        int dy = centery - y;
        return dx*dx+dy*dy <= (size/2)*(size/2);
    }

    public void setX(int x)
    {
        this.x=x;
    }
    public void setY(int y)
    {
        this.y=y;
    }
    public int getX()
    {
        return x;
    }
    public int getY()
    {
        return y;
    }
}
